<!-- 此页面代码没用到 -->
<template>
  <div>
    <PageTable :config="pageTableConfig"></PageTable>
  </div>
</template>
<script>
import AccountTypeEdit from "./AccountTypeEdit.vue";
export default {
  components: {},
  props: {},
  data() {
    return {
      pageTableConfig: {
        title: "账号类型管理",
        formDirection: "column", //default
        action: null,
        resource: null, //default
        customDataProcess: null, //default
        loadDataFn: this.loadData,
        columnsFn: this.generateColumns,
        autoFirst: true, //default false
        searchLabelPosition: "top", //default
        searchFields: [
          {
            label: this.$t("module.accountType.accountType"),
            field: "accountType",
            placeholder: "请输入" + this.$t("module.accountType.accountType"),
            maxlength: 50,
            size: "small"
          },
          {
            label: this.$t("module.accountType.protocolType"),
            field: "protocolParameter",
            placeholder: "请输入" + this.$t("module.accountType.protocolType"),
            maxlength: 50,
            size: "small"
          }
        ],
        formButtons: [{ optType: "search" }, { optType: "reset" }],
        tableButtons: [this.addTypeButton(this)]
      }
    };
  },
  computed: {},
  created: function() {},
  beforeMount: function() {},
  mounted: function() {},
  beforeDestroy: function() {},
  destroyed: function() {},
  methods: {
    loadData({ responseProcess, param }) {
      this.$store
        .dispatch("QueryAccountTypeList", param)
        .then(response => {
          // console.log(response);
          // debugger;
          return response;
        })
        .then(res => responseProcess(res));
    },
    generateColumns() {
      return [
        {
          title: this.$t("module.accountType.accountType"),
          key: "accountType",
          align: "left",
          sortable: "custom",
          width: 200
        },
        {
          title: this.$t("module.accountType.protocolType"),
          key: "protocolType",
          align: "left",
          width: 200
        },
        {
          title: this.$t("module.accountType.protocolParameter"),
          key: "protocolParameter"
        },
        {
          title: this.$t("common.operating"),
           align: "left",
          fixed: "right",
          width: 80,
          render: (h, params) => {
            return h("RowTools", {
              props: {
                data: [
                  {
                    type: "icon",
                    icon: "md-create",
                    text: this.$t("common.edit"),
                    handle: () => {
                      //edit(params.row);
                      new this.$pageModal(
                        AccountTypeEdit,
                        {
                          props: { accountTypeId: "1" }
                        },
                        () => {}
                      );
                    }
                  },
                  {
                    type: "icon",
                    icon: "ios-trash-outline",
                    text: this.$t("common.delete"),
                    handle: () => {
                      this.$Modal.confirm({
                        title: "操作提示",
                        content: "确定删除？",
                        onOk: () => {
                          this.$message.error("Clicked ok");
                          // window.$http
                          //   .post(`${window.RPConfig.user}/delete?id=${params.row.id}`)
                          //   .then(response => response.data)
                          //   .then(res => responseProcess(res));
                        }
                      });
                    }
                  }
                ]
              }
            });
          }
        },
      ];
    },
    addTypeButton(self) {
      return {
        optType: "create",
        handler() {
          new self.$pageModal(
            AccountTypeEdit,
            {
              props: {}
            },
            data => {
              if (data) {
                // window.alert("刷新列表");
              }
            }
          );
        }
      };
    }
  },
  watch: {},
  directives: {}
};
</script>
